from django import forms
from django.contrib.auth.forms import UserCreationForm, UserChangeForm
from django.core.exceptions import ValidationError

from .models import User


class UserCreationForm(UserCreationForm):

    password1 = forms.CharField(label='Пароль',
                                strip=False,
                                widget=forms.PasswordInput(attrs={"autocomplete": "new-password"}),
                                help_text='Пароль должен содержать не менее 8 символов',)

    password2 = forms.CharField(label='Подтверждение пароля',
                                strip=False,
                                widget=forms.PasswordInput(attrs={"autocomplete": "new-password"}),
                                help_text='Пароль должен содержать не менее 8 символов',)

    username = forms.CharField(max_length=250,
                               label='Имя пользователя')

    class Meta:
        model = User
        fields = ('username', 'email')


class UserChangeForm(UserChangeForm):

    class Meta:
        model = User
        fields = ('email',)
